/* eslint-disable react/no-deprecated */
"use client";

import React from "react";
import ReactDOM from "react-dom/client";
import Loading from "@/app/loading";

/**
 * 客户端组件发送请求时会需要使用Loading组件....
 * 使用函数控制动画的开启与关闭
 */
const loadingOpen = () => {
  const Node = document.createElement("div");
  Node.setAttribute("id", "client-loading");
  document.body.appendChild(Node);
  const root = ReactDOM.createRoot(document.getElementById("client-loading")!);
  root.render(<React.StrictMode><Loading /></React.StrictMode>);
}

const loadingClose = () => {
  document.getElementById("client-loading")?.remove();
}

export {loadingOpen,loadingClose}
